package com.mall.controller.backend;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mall.common.Const;
import com.mall.common.ResponseCode;
import com.mall.common.ServerResponse;
import com.mall.pojo.MmallUser;
import com.mall.service.ICountService;
import com.mall.service.IUserService;

@Controller
@RequestMapping("/manage/statistic/")
public class statisticManageController {

	@Autowired
	private ICountService countService;
	
	@Autowired
	private IUserService userService;
	
	@RequestMapping("/base_count")
	@ResponseBody
	public ServerResponse base_count(HttpSession session){
		
		
		MmallUser user = (MmallUser)session.getAttribute(Const.CURRENT_USER);
		if(user == null){
			return ServerResponse.createByErroerCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"NEED LOGIN");
		}
		 
		if(!userService.checkAdminRole(user).isSuccess()){
			return ServerResponse.createByErrorMessage("不是管理员,无权限操作");
		}
		
		return countService.count();
	}
}
